package com.smarth.zhizulian.popupwindow;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;

import com.smarth.zhizulian.R;
import com.smarth.zhizulian.activity.MissionActivity;

/**
 * Created by 18865 on 2018/3/2.
 */

public class GetOneDialog extends Dialog {
    public GetOneDialog(@NonNull Context context) {
        super(context, R.style.MyDialog);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_getone);
        findViewById(R.id.v_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MissionActivity.open(getContext());
                dismiss();
            }
        });

        findViewById(R.id.iv_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        // 动态设置自定义Dialog的显示内容的宽和高
        WindowManager m = getWindow().getWindowManager();
        Display d = m.getDefaultDisplay();  //为获取屏幕宽、高
        android.view.WindowManager.LayoutParams p = getWindow().getAttributes();  //获取对话框当前的参数值
        p.height = d.getHeight();   //高度设置为屏幕的0.3
        p.width = d.getWidth();    //宽度设置为全屏
        getWindow().setAttributes(p);     //设置生效
    }

}
